package com.share.bigdata.hdfs.web;

import com.share.bigdata.hdfs.service.HdfsService;
import com.share.common.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@Slf4j
@RestController
public class HdfsController {

    @Autowired
    private HdfsService hdfsService;

    @RequestMapping("/list/file")
    public Result listFiles() {
        Result result = null;
        try {
            List<String> list = hdfsService.listFiles("/");
            result = Result.success(list);
        } catch (IOException e) {
            result = Result.failure(e.getMessage());
            log.error("hdfs执行异常", e);
        }
        return result;
    }
}
